package leecode

import "sort"

func numberGame(nums []int) []int {
	sort.Ints(nums)
	var result []int
	stack := make([]int, 0)
	for len(nums) != 0 {
		stack = append(stack, nums[0])
		nums = nums[1:]
		for len(stack) == 2 {
			result = append(result, stack[len(stack)-1], stack[len(stack)-2])
			stack = []int{}
		}
	}
	return result
}
